<template>
	<div>
		 <el-button type="primary" ><router-link to="/adm/addgood">添加热点</router-link> </el-button>
		<el-table :data="tab" border style="width: 100%">
			<el-table-column fixed prop="name" label="名称" width="150">
			</el-table-column>
			<el-table-column prop="sn" label="编号" width="120">
			</el-table-column>
			<el-table-column prop="author" label="作者" width="120">
			</el-table-column>
			<el-table-column prop="maker" label="厂家" width="120">
			</el-table-column>
			<el-table-column prop="tmake" label="日期" width="120">
			</el-table-column>
			<el-table-column prop="stock" label="库存" width="120">
			</el-table-column>
			<el-table-column label="图片" width="120">
				<template slot-scope="scope">
					<el-image :src="`http://127.0.0.1/api/public/showimg/${scope.row.pic}`"></el-image>
				</template>
			</el-table-column>
			<el-table-column prop="address" label="操作" width="300">
				<template slot-scope="scope">
					<el-button type="primary" size="small" icon="el-icon-edit" @click="update(scope.row)">修改
					</el-button>
				</template>
			</el-table-column>
		</el-table>
		
	</div>
</template>

<script>
	export default {
		name: 'Allgoods',
		data() {
			return {
				tab: []
			}
		},
		mounted() {
			this.getAllGoods()
		},
		methods: {
			getAllGoods() {
				this.$get("/api/adm/book/findByPage/1/5").then((resp) => {
					resp.data.data.books.forEach((item) => {
						let time = new Date(item.tmake)
						item.date = time.getFullYear() + '年' + time.getMonth() + '月' + time.getDay() +
						'日';
						this.tab.push(item);
					})
					console.log(resp.data.data)
				})
			},
			update(good){
				console.log(55555)
				this.$router.push({path:'/adm/updategood',query:{good}})
			}
		}
	}
</script>

<style>
</style>
